import { createApp } from "vue";
import store from "./stores";
import Antd from "ant-design-vue";
import dayjs from "dayjs";
import "ant-design-vue/dist/antd.css";
import ProLayout, { PageContainer } from "@ant-design-vue/pro-layout";
import "@ant-design-vue/pro-layout/dist/style.css";

import App from "./App.vue";
import router from "./router";

import "@/styles/base.less";

import * as antIcons from "@ant-design/icons-vue"; // 引入ant icons所有的图标
async function start() {
  const app = createApp(App);

  const antIconsList = antIcons; // 重新赋值定义类型 避免后续遍历注册组件的时候ts报错
  for (const key in antIconsList) {
    app.component(key, antIconsList[key]);
  }
  app.config.globalProperties.$antIcons = antIcons; // 挂在vue实例上

  app.use(store);

  app.use(router).use(Antd).use(ProLayout).use(PageContainer);
  app.config.globalProperties.$filters = {
    formatDate: value => { if (!value) return ''; return dayjs(value).format('YYYY-MM-DD') },
    formatTime: value => { if (!value) return ''; return dayjs(value).format('YYYY-MM-DD HH:mm') }
  }
  app.mount("#app");
}

start();
